import React, { Component } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from "redux"
import { getNews, actions, getGroupons, getCountdown, getSeckill, getShowGoods, getCatelist, getShowCoupon } from '../../store/modules/home'
import { actions as indexActions} from '../../store/modules/index'
import Banner from './components/Banner/Banner'
import List from './components/List/List'
import Goods from './components/Goods/Goods'
import Top from '../../components/Top/Top'
import Groupons from './components/Groupons/Groupons'
import Seckill from './components/Seckill/Seckill'
import IndexGoods from "./components/IndexGoods/IndexGoods"
import "./home.css"
import Coupon from './components/Coupon/Coupon'
class Home extends Component {
    componentDidMount() {
        let { home: { reqNews, reqGroupon, reqCountdown, reqSeckill, reqIndexgoods, reqCate, reqCoupon } } = this.props
        console.log(this.props);
        reqNews()
        reqGroupon()
        reqCountdown()
        reqSeckill()
        reqIndexgoods()
        reqCate()
        reqCoupon()
        
    }
    render() {
        let title = "home"
        let { news, groupons, seckill, goods, cateList, home: { changeFilter},index:{reqCartadd}} = this.props
        console.log(this.props);
        return (
            <div>
                <Top title={title}></Top>
                <List cateList={cateList}></List>
                <Banner></Banner>
                <Goods news={news} reqCartadd={reqCartadd}></Goods>
                <Groupons groupons={groupons}></Groupons>
                <Seckill seckill={seckill}></Seckill>
                <IndexGoods goods={goods} changeFilter={changeFilter}></IndexGoods>
                <div className="home_b_div"></div>
            </div>
        )
    }
}
const mapStateToProps = (state) => ({
    news: getNews(state),
    groupons: getGroupons(state),
    countdown: getCountdown(state),
    seckill: getSeckill(state),
    goods: getShowGoods(state),
    cateList: getCatelist(state),
    coupon:getShowCoupon(state)
})

const mapDispatchToProps = dispatch => ({
    home: bindActionCreators(actions, dispatch),
    index: bindActionCreators(indexActions, dispatch)
})

export default connect(mapStateToProps, mapDispatchToProps)(Home)